package leetcode.oldVersion;

public class lc53 {
    public int maxSubArray(int[] nums) {
        int sum=0;
        int ans=nums[0];
        for(int i=0;i<nums.length;i++){
            if(sum<=0){
                sum=nums[i];
            }else {
                sum=sum+nums[i];
            }
            ans=Math.max(ans,sum);
        }
        return ans;
    }
}
